

import re

global_data= {}
resp = '{"code": "00", "userid":36807}'
s='userid----userid":(\w+)'

def post_handle_data(correlation_exp,resp):
    global global_data
    var_name= correlation_exp.split('----')[0]
    reg_exp= correlation_exp.split('----')[1]
    if re.search(reg_exp,resp):
        value= re.search(reg_exp,resp).group(1)
        global_data[var_name]= value
post_handle_data(s,resp)
print(global_data)


s= 'token----"token": "(\w+)"'
resp = '{"code": "00", "userid": 36814, "token": "bd89e8be04e6494c651a9ece242b5fe8", "login_time": "2023-02-22 21:17:42"} '
post_handle_data(s,resp)
print(global_data)